<template>
  <div id="radio_group01">
    <div class="radio_wrap">
      <div
        :class="{ radio_item: true, radio_item_blue: radio_value == item }"
        v-for="(item, index) in radio_values"
        :key="'radio_group01' + index"
        @click="changeTime(item)"
      >
        {{ item }}
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "radio_group01",
  data() {
    return {
      now_radio_value: this.radio_value,
    };
  },
  model: {
    prop: "radio_value",
    event: "returnBack",
  },
  /**
   * @vipLevel 传过来的vip等级,数据大盘判断vip等级==0 不让切换时间
   */
  props: ["radio_values", "radio_value","vipLevel"],
  created: function () {
    this.$watch("radio_value", function (newValue, oldValue) {
 
      this.now_radio_value = this.radio_value;
    });
  },
  methods:{
    changeTime(item){
      //vipLevel 父组件返回来的vip等级, 如果vip等级等于0 则不让用户切换
      if(this.vipLevel==0) {
        if (document.getElementsByClassName('el-message').length === 0) {
          this.$message({
            message: '您当前权限不足，请升级权限后点击查看',
            type: 'warning',
            offset: 90
          });
        }
        return
      }else{
        this.now_radio_value = item;
        this.$emit('returnBack', this.now_radio_value);
      }
    }
  }
};
</script>
<style scoped lang="less">
#radio_group01 {
  .radio_item {
    background-color: #fff;
    border: solid 1px #e5e5e5;
    cursor: pointer;
    outline: none;
    height: 32px;
    border-radius: 4px;
    font-size: 14px;
    color: #222222;
    line-height: 30px;
    padding: 0 18px;
    margin-left: 10px;
    box-sizing: border-box;
  }
  .radio_item_blue {
    color: #fff !important;
    background-color: transparent;
    border: solid 1px #fd7f2c !important;
    color: #fd7f2c !important;
  }
  .radio_item:first-child {
    margin-left: 0;
  }
  .radio_wrap {
    display: flex;
    flex-wrap: wrap;
  }
}
</style>
